package com.pentakill.mo.auth.user.web;

import com.pentakill.mo.auth.role.business.ebi.RoleEbi;
import com.pentakill.mo.auth.user.business.ebi.UserEbi;
import com.pentakill.mo.auth.user.vo.UserModel;
import com.pentakill.mo.util.base.BaseAction;

public class UserAction extends BaseAction {
	//注入角色ebi
	private RoleEbi roleEbi;

	private UserEbi userEbi;
	
	public void setUserEbi(UserEbi userEbi) {
		this.userEbi = userEbi;
	}

	public void setRoleEbi(RoleEbi roleEbi) {
		this.roleEbi = roleEbi;
	}
	
	
	public UserModel um;
	
	
	//登录
	public String login(){
		//TODO 未添加查询角色和资源加载
		boolean login;
//		UserModel um = new UserModel();
//		um.setName("admin");
//		um.setLoginID("123");
//		um.setPassword("123");
		login = userEbi.userByN_P(um);
		if (login) {
			putSession("user", um);
			System.out.println("登录成功");
		}else {
			System.out.println("失败");
		}
		
		//TODO 未指定视图
		return null;
	}
	
	//普通用户注册
	public String register(){
		
		userEbi.userByRegister(um);
		
		//TODO未指定视图
		return null;
	}
	
	public String exit(){
		
		putSession("user",null);
		
		//TODO未指定视图
		return null;
	}
	//社团 管理员   用户注册  
	//需要预先加载角色信息
	public String ACRegister(){		
		userEbi.ACByRegister(um);
		
		//TODO未指定视图
		return null;
	}
	
}
